home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_03
/
kamradt
/
lowlev.txt
< prev
next >
Wrap
Text File
|
1994-02-07
|
563b
|
20 lines
Figure 10a. Results of an inefficient += operator.
1.0235 500 void PadWithSpaces(CString &str, int count)
{
5.0346 20000 while(count--)
30.0397 19000 str += " ";
1.4354 500 }
Figure 10b. Improved performance with low-level C-strings.
1.0233 500 void PadWithSpaces(CString &str, int count)
{
2.4505 500 char *tmp = new char[count+1];
3.2930 500 memset(tmp,' ',count);
0.9438 500 tmp[count] = '\0';
5.3049 500 str += tmp;
1.9430 500 delete[] tmp;
1.4353 500 }